<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1.0,user-scalable=0"/>

<title>Xnote</title>
<link rel="shortcut icon" href="/static/favicon.ico"/>
<link rel="bookmark" href="/static/favicon.ico"/>
<link rel="stylesheet" href="/static/css/common.css"/>
<script src="/static/lib/jquery/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
  window.xuser = "{{_user_name}}";
</script>
<script type="text/javascript" src="/static/js/utils.js"></script>
<script type="text/javascript" src="/system/stats"></script>
<script type="text/javascript" src="/static/js/xnote-ui.js"></script>

{% block head %} {% end %}

{% if xconfig.DEBUG_HTML_BOX %}
<style>
  * {
    box-sizing: border-box;
    border: solid 1px red;
  }
</style>
{% end %}

</head>
<body>
<div class="header">
  <div class="toggleMenu" style="margin-left: 15px; cursor: pointer;"></div>
</div>

<div class="nav-search-box">
  <form id="searchForm" method="GET" action="{{?action,'/search/search'}}">
    <div class="x-center">
      <input id="key" name="key" class="nav-search-input" placeholder="搜索或指令" value="{{?key}}"/>
      <input class="hide" name="category" value="{{?category}}" />
      <button class="nav-search-btn">搜</button>
    </div>
  </form>
</div>

<div class="nav-top">
  <ul class="x-center">
    <li><a href="/note/group">知识库</a></li>
    {% if _has_login %}
    <li><a href="/tools/message?status=created">记事({{_notice_count}})</a></li>
    {% end %}
    <li><a href="/system/index">系统</a></li>
    <li><a href="/wiki/README.md">关于</a></li>
  </ul>
</div>

<div class="main x-center">
  
  {% for item in xconfig.get_notice_list('today', _user_name) %}
    <div class="notice">{{item.message}}</div>
  {% end %}

  {% block body %} {% end %}
  <div class="footer"></div>
</div>
<!-- Main Part End -->
<div class="x-dialog-background"></div>

<script>

$(function() {
  function expandMenu(ele, delay) {
    // 禁用
    return;
    if (delay == undefined) {
      delay = 0;
    }
    var parent = ele.parent().parent(); //获取当前页签的父级的父级
    var labeul = ele.parent("li").find(">ul");
    if (ele.parent().hasClass('open') == false) {
      //展开未展开
      parent.find('ul').slideUp(delay);
      parent.find("li").removeClass("open");
      parent.find('li a').removeClass("active").find(".arrow").removeClass("open");
      ele.parent("li").addClass("open").find(labeul).slideDown(delay);
      ele.addClass("active").find(".arrow").addClass("open")
    } else {
      ele.parent("li").removeClass("open").find(labeul).slideUp(delay);
      if (ele.parent().find("ul").length > 0) {
        ele.removeClass("active").find(".arrow").removeClass("open");
      } else {
        ele.addClass("active");
      }
    }
  }
  // nav收缩展开
  $('.navMenu li a').on('click',
    function() {
      expandMenu($(this), 300);
  });


  function showSideBar() {
    $(".navMenubox").animate({"margin-left": "0px"});
    $("#poweredBy").show();
  }

  function hideSideBar() {
    $(".navMenubox").animate({"margin-left": "-200px"});
    $("#poweredBy").hide();
  }

  function checkResize() {
    if ($(".navMenubox").is(":animated")) {
      return;
    }
    if (window.innerWidth < 600) {
      // 移动端，兼容下不支持@media的浏览器 
      hideSideBar();
    } else {
      showSideBar();
    }
  }

  function toggleMenu() {
    var marginLeft = $(".navMenubox").css("margin-left");
    if (marginLeft == "0px") {
      hideSideBar();
    } else {
      showSideBar();
    }
  }

  $(".toggleMenu").on("click", function () {
    toggleMenu();
  });

  var pathname = location.pathname;
  if (/\/file\/.*/.test(pathname)) {
    expandMenu($("#navFile"));
  }
  if (pathname != "/tools/message"
      && (/\/system\/.*/.test(pathname) 
      || /\/tools\/.*/.test(pathname))) {
    expandMenu($("#navSystem"));
  }
});
</script>
</body>
</html>
